deploy: Correctly use libmount unref() calls rather than free()
authorColin Walters <walters@verbum.org>
Thu, 23 Feb 2017 14:40:17 +0000 (09:40 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 23 Feb 2017 15:31:25 +0000 (15:31 +0000)
commit0817be61a17cc8b770cad54196182ac9c3109caf
tree02448d18c772b7a1c1c7a48167e3c6fd8eb21b59
parent09b392675aa7ede9eb108cce478cc491080ac1f0
deploy: Correctly use libmount unref() calls rather than free()

We saw a random ostree SEGV start popping up in our CI environment:
https://github.com/projectatomic/rpm-ostree/pull/641#issuecomment-281870424

Looking at this code more and comparing it to what util-linux does, I noticed we
had a write-after-free, since `mnt_unref_table()` will invoke
`mnt_unref_cache()` on its cache, and that function does:

```
if (cache) {
cache->rfcount--;
```

unconditionally.

Fix this by using `unref()`.

Closes: #705
Approved by: jlebon
src/libostree/ostree-sysroot-deploy.c